package com.masterclient.app.modules.aftersale;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.eoner.baselibrary.bean.aftersale.NewRefundDetailsBean;
import com.eoner.baselibrary.utils.ScreenUtils;
import com.eoner.baselib.utils.toast.ToastUtil;
import com.masterclient.app.R;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * 作者：sean
 * 创建时间：2017/9/5 10:18
 * 功能说明：
 */
public class AfterSaleDialog extends Dialog implements TextWatcher {

    private NewRefundDetailsBean mData;
    private boolean isRefuse;
    private OnClickAfterSaleListener onClickAfterSaleListener;

    private TextView tvAfterSaleConfirm;
    private TextView tvAfterSaleName;
    private TextView tvAfterSaleAddress;
    private TextView tvAfterSaleUpdate;
    private String operate;
    private String addressId;

    AfterSaleDialog(@NonNull Context context, NewRefundDetailsBean bean, boolean isRefuse, OnClickAfterSaleListener onClickAfterSaleListener) {
        super(context, R.style.MyDialog);
        mData = bean;
        this.isRefuse = isRefuse;
        this.onClickAfterSaleListener = onClickAfterSaleListener;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_after_sale);
        setCanceledOnTouchOutside(true);

        ImageView ivCancel = findViewById(R.id.iv_cancel);
        ivCancel.setOnClickListener(view -> dismiss());

        TextView tvAfterSaleDes = findViewById(R.id.tv_after_sale_des);
        TextView tvAfterSaleTitle = findViewById(R.id.tv_after_sale_title);

        View viewMoneyType = findViewById(R.id.view_money_type);
        TextView tvAfterSaleMoneyType = findViewById(R.id.tv_after_sale_money_type);
        TextView tvAfterSaleRefundMoney = findViewById(R.id.tv_after_sale_refund_money);
        TextView tvAfterSaleRefundMoneyDes = findViewById(R.id.tv_after_sale_refund_money_des);


        View viewAfterSaleType = findViewById(R.id.view_after_sale_type);
        TextView tvAfterSaleType = findViewById(R.id.tv_after_sale_type);

        View viewAfterSaleMoney = findViewById(R.id.view_after_sale_money);
        TextView tvAfterSaleMoney = findViewById(R.id.tv_after_sale_money);
        TextView tvAfterSaleMoneyDes = findViewById(R.id.tv_after_sale_money_des);

        View viewRefundNum = findViewById(R.id.view_refund_num);
        TextView tvRefundNum = findViewById(R.id.tv_refund_num);

        View viewAfterSaleAddress = findViewById(R.id.view_after_sale_address);
        tvAfterSaleName = findViewById(R.id.tv_after_sale_name);
        tvAfterSaleAddress = findViewById(R.id.tv_after_sale_address);
        tvAfterSaleUpdate = findViewById(R.id.tv_after_sale_update);

        View viewAfterSaleRefund = findViewById(R.id.view_after_sale_refund);
        TextView tvAfterSaleRefundDes = findViewById(R.id.tv_after_sale_refund_des);
        EditText editAfterSaleRefund = findViewById(R.id.edit_after_sale_refund);

        View viewAfterSaleNum = findViewById(R.id.view_after_sale_num);
        EditText editAfterSaleNum = findViewById(R.id.edit_after_sale_num);

        View viewAfterSaleRemark = findViewById(R.id.view_after_sale_remark);
        EditText editAfterSaleRemark = findViewById(R.id.edit_after_sale_remark);
        TextView tvAfterSaleRemarkNum = findViewById(R.id.tv_after_sale_remark_num);
        tvAfterSaleConfirm = findViewById(R.id.tv_after_sale_confirm);
        editAfterSaleRemark.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                tvAfterSaleRemarkNum.setText(String.format("%d/100", charSequence.length()));
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });

        if ("1".equals(mData.buttonArr.moneyRefuseApproveBtn) && mData.buttonArr.isClickMoneyRefuseApproveBtn) {
            //仅退款---审核拒绝
            tvAfterSaleTitle.setVisibility(View.GONE);
            viewAfterSaleType.setVisibility(View.GONE);
            viewAfterSaleMoney.setVisibility(View.GONE);
            viewAfterSaleAddress.setVisibility(View.GONE);
            viewAfterSaleRefund.setVisibility(View.GONE);
            viewAfterSaleNum.setVisibility(View.GONE);
            viewAfterSaleRemark.setVisibility(View.VISIBLE);
            editAfterSaleRemark.setHint("拒绝原因");
            editAfterSaleRemark.addTextChangedListener(this);
            tvAfterSaleConfirm.setBackgroundResource(R.drawable.shape_radius18_d8d8d8);

            tvAfterSaleConfirm.setOnClickListener(v -> {
                JSONObject jsonObject = new JSONObject();
                try {
                    operate = "2";
                    if (TextUtils.isEmpty(editAfterSaleRemark.getText().toString())) {
                        ToastUtil.showToast("请输入相关内容");
                        return;
                    }
                    jsonObject.put("refuse_reason", editAfterSaleRemark.getText().toString());
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                onClickAfterSaleListener.clickConfirm(mData.refundNo, operate,
                        jsonObject.toString());
            });
        } else if ("1".equals(mData.buttonArr.moneyPayConfirmBtn) && mData.buttonArr.isClickMoneyPayConfirmBtn) {
            //仅退款---确认退款
            tvAfterSaleTitle.setVisibility(View.GONE);
            viewAfterSaleType.setVisibility(View.GONE);
            viewAfterSaleMoney.setVisibility(View.GONE);
            viewAfterSaleAddress.setVisibility(View.GONE);
            viewAfterSaleRefund.setVisibility(View.GONE);
            viewAfterSaleNum.setVisibility(View.GONE);
            viewAfterSaleRemark.setVisibility(View.VISIBLE);
            if (isRefuse) {
                editAfterSaleRemark.setHint("拒绝原因");
            } else {
                editAfterSaleRemark.setHint("退款备注");
            }
            editAfterSaleRemark.addTextChangedListener(this);
            tvAfterSaleConfirm.setBackgroundResource(R.drawable.shape_radius18_d8d8d8);

            tvAfterSaleConfirm.setOnClickListener(v -> {
                if (TextUtils.isEmpty(editAfterSaleRemark.getText().toString())) {
                    ToastUtil.showToast("请输入相关内容");
                    return;
                }
                JSONObject jsonObject = new JSONObject();
                try {
                    if (isRefuse) {
                        operate = "2";
                        jsonObject.put("refuse_reason", editAfterSaleRemark.getText().toString());
                    } else {
                        operate = "1";
                        jsonObject.put("refund_remark", editAfterSaleRemark.getText().toString());
                    }

                } catch (JSONException e) {
                    e.printStackTrace();
                }
                onClickAfterSaleListener.clickConfirm(mData.refundNo, operate,
                        jsonObject.toString());
            });
        } else if ("1".equals(mData.buttonArr.productRefuseApproveBtn) && mData.buttonArr.isClickProductRefuseApproveBtn) {
            //退货退款---审核拒绝
            tvAfterSaleTitle.setVisibility(View.GONE);
            viewAfterSaleType.setVisibility(View.GONE);
            viewAfterSaleMoney.setVisibility(View.GONE);
            viewAfterSaleAddress.setVisibility(View.GONE);
            viewAfterSaleRefund.setVisibility(View.GONE);
            viewAfterSaleNum.setVisibility(View.GONE);
            viewAfterSaleRemark.setVisibility(View.VISIBLE);
            editAfterSaleRemark.setHint("拒绝原因");
            editAfterSaleRemark.addTextChangedListener(this);
            tvAfterSaleConfirm.setBackgroundResource(R.drawable.shape_radius18_d8d8d8);

            tvAfterSaleConfirm.setOnClickListener(v -> {
                JSONObject jsonObject = new JSONObject();
                try {
                    operate = "2";
                    if (TextUtils.isEmpty(editAfterSaleRemark.getText().toString())) {
                        ToastUtil.showToast("请输入相关内容");
                        return;
                    }
                    jsonObject.put("refuse_reason", editAfterSaleRemark.getText().toString());
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                onClickAfterSaleListener.clickConfirm(mData.refundNo, operate,
                        jsonObject.toString());
            });
        } else if ("1".equals(mData.buttonArr.productReceiveRefuseBtn) && mData.buttonArr.isClickProductReceiveRefuseBtn) {
            //退货退款---拒绝收货
            tvAfterSaleTitle.setVisibility(View.GONE);
            viewAfterSaleType.setVisibility(View.GONE);
            viewAfterSaleMoney.setVisibility(View.GONE);
            viewAfterSaleAddress.setVisibility(View.GONE);
            viewAfterSaleRefund.setVisibility(View.GONE);
            viewAfterSaleNum.setVisibility(View.GONE);
            viewAfterSaleRemark.setVisibility(View.VISIBLE);
            editAfterSaleRemark.setHint("拒绝原因");
            editAfterSaleRemark.addTextChangedListener(this);
            tvAfterSaleConfirm.setBackgroundResource(R.drawable.shape_radius18_d8d8d8);
            tvAfterSaleConfirm.setOnClickListener(v -> {
                JSONObject jsonObject = new JSONObject();
                try {
                    if (TextUtils.isEmpty(editAfterSaleRemark.getText().toString())) {
                        ToastUtil.showToast("请输入相关内容");
                        return;
                    }
                    operate = "2";
                    jsonObject.put("refuse_reason", editAfterSaleRemark.getText().toString());
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                onClickAfterSaleListener.clickConfirm(mData.refundNo, operate,
                        jsonObject.toString());
            });
        } else if ("1".equals(mData.buttonArr.productPayConfirmBtn) && mData.buttonArr.isClickProductPayConfirmBtn) {
            //退货退款---确认退款
            tvAfterSaleTitle.setVisibility(View.GONE);
            viewAfterSaleType.setVisibility(View.GONE);
            viewAfterSaleMoney.setVisibility(View.GONE);
            viewAfterSaleAddress.setVisibility(View.GONE);
            viewAfterSaleRefund.setVisibility(View.GONE);
            viewAfterSaleNum.setVisibility(View.GONE);
            viewAfterSaleRemark.setVisibility(View.VISIBLE);
            if (isRefuse) {
                editAfterSaleRemark.setHint("拒绝原因");
            } else {
                editAfterSaleRemark.setHint("退款备注");
            }
            editAfterSaleRemark.addTextChangedListener(this);
            tvAfterSaleConfirm.setBackgroundResource(R.drawable.shape_d8d8d8);

            tvAfterSaleConfirm.setOnClickListener(v -> {
                if (TextUtils.isEmpty(editAfterSaleRemark.getText().toString())) {
                    ToastUtil.showToast("请输入相关内容");
                    return;
                }
                JSONObject jsonObject = new JSONObject();
                try {
                    if (isRefuse) {
                        operate = "2";
                        jsonObject.put("refuse_reason", editAfterSaleRemark.getText().toString());
                    } else {
                        operate = "1";
                        jsonObject.put("refund_remark", editAfterSaleRemark.getText().toString());
                    }

                } catch (JSONException e) {
                    e.printStackTrace();
                }
                onClickAfterSaleListener.clickConfirm(mData.refundNo, operate,
                        jsonObject.toString());
            });
        } else if ("1".equals(mData.buttonArr.moneyPassApproveBtn) && mData.buttonArr.isClickMoneyPassApproveBtn) {
            //仅退款---审核通过
            tvAfterSaleTitle.setVisibility(View.VISIBLE);
            viewAfterSaleType.setVisibility(View.VISIBLE);
            tvAfterSaleType.setText("仅退款");
            viewAfterSaleMoney.setVisibility(View.VISIBLE);
            tvAfterSaleMoney.setText(mData.refundAmount);
            tvAfterSaleMoneyDes.setText(String.format("(%s%s)", mData.refundPaymentTypeDesc, mData.refundAmount));
            viewAfterSaleAddress.setVisibility(View.GONE);
            viewAfterSaleRefund.setVisibility(View.GONE);
            viewAfterSaleNum.setVisibility(View.GONE);
            viewAfterSaleRemark.setVisibility(View.GONE);
            tvAfterSaleConfirm.setOnClickListener(v -> {
                JSONObject jsonObject = new JSONObject();
                try {
                    operate = "1";
                    jsonObject.put("refund_amount", mData.refundAmount);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                onClickAfterSaleListener.clickConfirm(mData.refundNo, operate,
                        jsonObject.toString());
            });
        } else if ("1".equals(mData.buttonArr.moneyPayRefuseBtn) && mData.buttonArr.isClickMoneyPayRefuseBtn) {
            //仅退款---拒绝退款
            tvAfterSaleTitle.setVisibility(View.GONE);
            viewAfterSaleType.setVisibility(View.GONE);
            viewAfterSaleMoney.setVisibility(View.GONE);
            viewAfterSaleAddress.setVisibility(View.GONE);
            viewAfterSaleRefund.setVisibility(View.GONE);
            viewAfterSaleNum.setVisibility(View.GONE);
            viewAfterSaleRemark.setVisibility(View.VISIBLE);
            if (isRefuse) {
                editAfterSaleRemark.setHint("拒绝原因");
            } else {
                editAfterSaleRemark.setHint("退款备注");
            }
            editAfterSaleRemark.addTextChangedListener(this);
            tvAfterSaleConfirm.setBackgroundResource(R.drawable.shape_d8d8d8);

            tvAfterSaleConfirm.setOnClickListener(v -> {
                if (TextUtils.isEmpty(editAfterSaleRemark.getText().toString())) {
                    ToastUtil.showToast("请输入相关内容");
                    return;
                }
                JSONObject jsonObject = new JSONObject();
                try {
                    if (isRefuse) {
                        operate = "2";
                        jsonObject.put("refuse_reason", editAfterSaleRemark.getText().toString());
                    } else {
                        operate = "1";
                        jsonObject.put("refund_remark", editAfterSaleRemark.getText().toString());
                    }

                } catch (JSONException e) {
                    e.printStackTrace();
                }
                onClickAfterSaleListener.clickConfirm(mData.refundNo, operate,
                        jsonObject.toString());
            });
        } else if ("1".equals(mData.buttonArr.productPassApproveBtn) && mData.buttonArr.isClickProductPassApproveBtn) {
            //退货退款---审核通过
            tvAfterSaleTitle.setVisibility(View.GONE);
            viewAfterSaleType.setVisibility(View.VISIBLE);
            tvAfterSaleType.setText("退货退款");
            viewAfterSaleMoney.setVisibility(View.VISIBLE);
            tvAfterSaleMoney.setText(mData.refundAmount);
            tvAfterSaleMoneyDes.setText(String.format("(%s%s)", mData.refundPaymentTypeDesc, mData.refundAmount));
            viewAfterSaleAddress.setVisibility(View.VISIBLE);
            tvAfterSaleName.setText("+ 添加退货地址");
            tvAfterSaleAddress.setVisibility(View.GONE);
            tvAfterSaleUpdate.setVisibility(View.GONE);
            viewAfterSaleRefund.setVisibility(View.GONE);
            viewAfterSaleNum.setVisibility(View.GONE);
            viewAfterSaleRemark.setVisibility(View.GONE);
            viewAfterSaleAddress.setOnClickListener(v -> onClickAfterSaleListener.clickUpdateAddress());
            tvAfterSaleConfirm.setOnClickListener(v -> {
                JSONObject jsonObject = new JSONObject();
                try {
                    operate = "1";
                    jsonObject.put("address_id", addressId);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                onClickAfterSaleListener.clickConfirm(mData.refundNo, operate,
                        jsonObject.toString());
            });
        } else if ("1".equals(mData.buttonArr.productWaitShipmentCancelBtn) && mData.buttonArr.isClickProductWaitShipmentCancelBtn) {
            //退货退款---用户协商取消
            tvAfterSaleTitle.setVisibility(View.GONE);
            viewAfterSaleType.setVisibility(View.GONE);
            viewAfterSaleMoney.setVisibility(View.GONE);
            viewAfterSaleAddress.setVisibility(View.GONE);
            viewAfterSaleRefund.setVisibility(View.GONE);
            viewAfterSaleNum.setVisibility(View.GONE);
            viewAfterSaleRemark.setVisibility(View.VISIBLE);
            editAfterSaleRemark.setHint("拒绝原因");
            editAfterSaleRemark.addTextChangedListener(this);
            tvAfterSaleConfirm.setBackgroundResource(R.drawable.shape_d8d8d8);

            tvAfterSaleConfirm.setOnClickListener(v -> {
                if (TextUtils.isEmpty(editAfterSaleRemark.getText().toString())) {
                    ToastUtil.showToast("请输入相关内容");
                    return;
                }
                JSONObject jsonObject = new JSONObject();
                try {
                    if (isRefuse) {
                        operate = "2";
                        jsonObject.put("refuse_reason", editAfterSaleRemark.getText().toString());
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                onClickAfterSaleListener.clickConfirm(mData.refundNo, operate,
                        jsonObject.toString());
            });
        } else if ("1".equals(mData.buttonArr.productReceiveConfirmBtn) && mData.buttonArr.isClickProductReceiveConfirmBtn) {
            //退货退款---确认收货
            tvAfterSaleTitle.setVisibility(View.VISIBLE);
            viewAfterSaleType.setVisibility(View.VISIBLE);
            tvAfterSaleType.setText("退货退款");
            viewAfterSaleMoney.setVisibility(View.VISIBLE);
            tvAfterSaleMoney.setText(mData.refundAmount);
            tvAfterSaleMoneyDes.setText(String.format("(%s%s)", mData.refundPaymentTypeDesc, mData.refundAmount));
            viewAfterSaleAddress.setVisibility(View.GONE);
            viewAfterSaleRefund.setVisibility(View.GONE);
            viewAfterSaleNum.setVisibility(View.GONE);
            viewAfterSaleRemark.setVisibility(View.GONE);

            tvAfterSaleConfirm.setOnClickListener(v -> {
                JSONObject jsonObject = new JSONObject();
                try {
                    operate = "1";
                    jsonObject.put("refund_amount", mData.refundAmount);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                onClickAfterSaleListener.clickConfirm(mData.refundNo, operate,
                        jsonObject.toString());
            });
        }else if ("1".equals(mData.buttonArr.productPayRefuseBtn) && mData.buttonArr.isClickProductPayRefuseBtn) {
            //退货退款---拒绝退款
            tvAfterSaleTitle.setVisibility(View.GONE);
            viewAfterSaleType.setVisibility(View.GONE);
            viewAfterSaleMoney.setVisibility(View.GONE);
            viewAfterSaleAddress.setVisibility(View.GONE);
            viewAfterSaleRefund.setVisibility(View.GONE);
            viewAfterSaleNum.setVisibility(View.GONE);
            viewAfterSaleRemark.setVisibility(View.VISIBLE);
            if (isRefuse) {
                editAfterSaleRemark.setHint("拒绝原因");
            } else {
                editAfterSaleRemark.setHint("退款备注");
            }
            editAfterSaleRemark.addTextChangedListener(this);
            tvAfterSaleConfirm.setBackgroundResource(R.drawable.shape_d8d8d8);

            tvAfterSaleConfirm.setOnClickListener(v -> {
                if (TextUtils.isEmpty(editAfterSaleRemark.getText().toString())) {
                    ToastUtil.showToast("请输入相关内容");
                    return;
                }
                JSONObject jsonObject = new JSONObject();
                try {
                    if (isRefuse) {
                        operate = "2";
                        jsonObject.put("refuse_reason", editAfterSaleRemark.getText().toString());
                    } else {
                        operate = "1";
                        jsonObject.put("refund_remark", editAfterSaleRemark.getText().toString());
                    }

                } catch (JSONException e) {
                    e.printStackTrace();
                }
                onClickAfterSaleListener.clickConfirm(mData.refundNo, operate,
                        jsonObject.toString());
            });
        }else if ("1".equals(mData.buttonArr.moneyBehalfPassApproveBtn) && mData.buttonArr.isClickMoneyBehalfPassApproveBtn) {
            //被提货关联仅退款审核通过
            tvAfterSaleDes.setVisibility(View.VISIBLE);
            tvAfterSaleTitle.setVisibility(View.VISIBLE);
            viewMoneyType.setVisibility(View.VISIBLE);
            tvAfterSaleMoneyType.setText("仅退款");
            tvAfterSaleRefundMoney.setText(mData.refundAmount);
            tvAfterSaleRefundMoneyDes.setText(String.format("(%s%s)", mData.refundPaymentTypeDesc, mData.refundAmount));
            tvAfterSaleConfirm.setText("同意");

            viewAfterSaleMoney.setVisibility(View.GONE);
            viewAfterSaleType.setVisibility(View.GONE);
            viewAfterSaleAddress.setVisibility(View.GONE);
            viewAfterSaleRefund.setVisibility(View.GONE);
            viewAfterSaleNum.setVisibility(View.GONE);
            viewAfterSaleRemark.setVisibility(View.GONE);
            tvAfterSaleConfirm.setOnClickListener(v -> {
                JSONObject jsonObject = new JSONObject();
                try {
                    operate = "1";
                    jsonObject.put("refund_amount", mData.refundAmount);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                onClickAfterSaleListener.clickConfirm(mData.refundNo, operate,
                        jsonObject.toString());
            });
        } else if ("1".equals(mData.buttonArr.productCustodyPassApproveBtn) && mData.buttonArr.isClickProductCustodyPassApproveBtn) {
            //保管退货退款审核通过
            viewAfterSaleType.setVisibility(View.VISIBLE);
            tvAfterSaleType.setText("退货退款");
            viewAfterSaleMoney.setVisibility(View.VISIBLE);
            tvAfterSaleMoney.setText(mData.refundAmount);
            tvAfterSaleMoneyDes.setText(String.format("(%s%s)", mData.refundPaymentTypeDesc, mData.refundAmount));
            viewRefundNum.setVisibility(View.VISIBLE);
            tvRefundNum.setText(mData.refundNum);

            tvAfterSaleTitle.setVisibility(View.GONE);
            viewAfterSaleAddress.setVisibility(View.GONE);
            viewAfterSaleRefund.setVisibility(View.GONE);
            viewAfterSaleNum.setVisibility(View.GONE);
            viewAfterSaleRemark.setVisibility(View.GONE);
            tvAfterSaleConfirm.setOnClickListener(v -> {
                JSONObject jsonObject = new JSONObject();
                try {
                    operate = "1";
                    jsonObject.put("refund_amount", mData.refundAmount);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                onClickAfterSaleListener.clickConfirm(mData.refundNo, operate,
                        jsonObject.toString());
            });
        }
    }

    @Override
    protected void onStart() {
        super.onStart();
        Window window = getWindow();
        WindowManager.LayoutParams windowParams = window.getAttributes();
        window.setGravity(Gravity.CENTER);
        windowParams.width = ScreenUtils.getScreenWidth();
        window.setBackgroundDrawableResource(android.R.color.transparent);
        window.setAttributes(windowParams);
    }

    void updateAddress(String addressId, String name, String phone, String address) {
        this.addressId = addressId;
        tvAfterSaleName.setText(String.format("%s  %s", name, phone));
        tvAfterSaleName.setTextColor(Color.parseColor("#525866"));
        tvAfterSaleAddress.setVisibility(View.VISIBLE);
        tvAfterSaleAddress.setText(address);
        tvAfterSaleUpdate.setVisibility(View.VISIBLE);
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        if (s.length() > 0) {
            tvAfterSaleConfirm.setBackgroundResource(R.drawable.shape_212121);
        } else {
            tvAfterSaleConfirm.setBackgroundResource(R.drawable.shape_d8d8d8);
        }
    }

    @Override
    public void afterTextChanged(Editable s) {

    }

    interface OnClickAfterSaleListener {
        void clickUpdateAddress();

        void clickConfirm(String refund_no, String operate, String operateData);
    }
}
